#include "pool.h"
#include <string>
using std::ostream;
using std::string;

class MyObject
{
	private:
	static Pool pool;
	string name;
	int id;

	// constructor
	MyObject(int i, const string& nm):name(nm), id(i){}
	
	//dissabling copy and assignment opperator
	MyObject(const MyObject&);
	MyObject& operator=(const MyObject&);
   
public:
   static void* operator new(size_t)
   {
      return pool.allocate();
   }
   static void operator delete(void* p)
   {
      pool.deallocate(p);
   }
   static MyObject* create(int id, const string& name) // Factory method
   {
      return new MyObject(id, name);
   }
   friend ostream& operator<<(ostream&, const MyObject&);
};

